from selenium import webdriver
from time import sleep
from selenium.webdriver.common.by import By

driver = webdriver.Edge()
driver.get("https://www.baidu.com/")
driver.maximize_window()

driver.find_element(By.LINK_TEXT,'新闻').click()
# 切换新窗口
driver.switch_to.window(driver.window_handles[-1])
sleep(2)
driver.find_element(By.PARTIAL_LINK_TEXT,'千年瓷都的“青春范儿”').click()
driver.close()
# 切换新窗口
driver.switch_to.window(driver.window_handles[-1])
sleep(2)
driver.save_screenshot('baidu.png')

# 滚动3000像素
# driver.execute_script("window.scrollTo(0,3000)")
# sleep(2)
# # 滚动到底部
# driver.execute_script('window.scrollTo(0,document.body.scrollHeight)')
# sleep(2)
# # 滚动到顶部
# driver.execute_script('window.scrollTo(0,0)')

sleep(5)